package com.fitness.front.controller;

import com.fitness.front.modal.response.ServerResponseEntity;
import com.fitness.front.service.impl.common.UploadFileServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/front/common/upload")
public class UploadFileController {


    private final UploadFileServiceImpl uploadFileService;

    //    @SaCheckLogin
    @PostMapping
    public ServerResponseEntity<String> upload(MultipartFile file) throws Exception {
        String fileName = file.getOriginalFilename();  // 文件名
        String url = uploadFileService.uploadFile(file.getInputStream(),fileName);
        return ServerResponseEntity.success(url);
    }
}
